<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - /usr/include/boost/date_time/gregorian/greg_date.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../../index.html">top level</a> - <a href="index.html">usr/include/boost/date_time/gregorian</a> - greg_date.hpp<span style="font-size: 80%;"> (source / <a href="greg_date.hpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">8</td>
            <td class="headerCovTableEntry">11</td>
            <td class="headerCovTableEntryLo">72.7 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:50:33</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">2</td>
            <td class="headerCovTableEntry">2</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #ifndef GREG_DATE_HPP___</a>
<span class="lineNum">       2 </span>            : #define GREG_DATE_HPP___
<span class="lineNum">       3 </span>            : 
<span class="lineNum">       4 </span>            : /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
<span class="lineNum">       5 </span>            :  * Use, modification and distribution is subject to the
<span class="lineNum">       6 </span>            :  * Boost Software License, Version 1.0. (See accompanying
<span class="lineNum">       7 </span>            :  * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       8 </span>            :  * Author: Jeff Garland
<span class="lineNum">       9 </span>            :  * $Date$
<span class="lineNum">      10 </span>            :  */
<span class="lineNum">      11 </span>            : 
<span class="lineNum">      12 </span>            : #include &lt;boost/throw_exception.hpp&gt;
<span class="lineNum">      13 </span>            : #include &lt;boost/date_time/date.hpp&gt;
<span class="lineNum">      14 </span>            : #include &lt;boost/date_time/special_defs.hpp&gt;
<span class="lineNum">      15 </span>            : #include &lt;boost/date_time/gregorian/greg_calendar.hpp&gt;
<span class="lineNum">      16 </span>            : #include &lt;boost/date_time/gregorian/greg_duration.hpp&gt;
<span class="lineNum">      17 </span>            : 
<span class="lineNum">      18 </span>            : namespace boost {
<span class="lineNum">      19 </span>            : namespace gregorian {
<span class="lineNum">      20 </span>            : 
<span class="lineNum">      21 </span>            :   //bring special enum values into the namespace
<span class="lineNum">      22 </span>            :   using date_time::special_values;
<span class="lineNum">      23 </span>            :   using date_time::not_special;
<span class="lineNum">      24 </span>            :   using date_time::neg_infin;
<span class="lineNum">      25 </span>            :   using date_time::pos_infin;
<span class="lineNum">      26 </span>            :   using date_time::not_a_date_time;
<span class="lineNum">      27 </span>            :   using date_time::max_date_time;
<span class="lineNum">      28 </span>            :   using date_time::min_date_time;
<span class="lineNum">      29 </span>            : 
<span class="lineNum">      30 </span>            :   //! A date type based on gregorian_calendar
<span class="lineNum">      31 </span>            :   /*! This class is the primary interface for programming with
<span class="lineNum">      32 </span>            :       greogorian dates.  The is a lightweight type that can be
<span class="lineNum">      33 </span>            :       freely passed by value.  All comparison operators are
<span class="lineNum">      34 </span>            :       supported.
<span class="lineNum">      35 </span>            :       \ingroup date_basics
<span class="lineNum">      36 </span>            :   */
<span class="lineNum">      37 </span>            :   class date : public date_time::date&lt;date, gregorian_calendar, date_duration&gt;
<span class="lineNum">      38 </span>            :   {
<span class="lineNum">      39 </span>            :    public:
<span class="lineNum">      40 </span>            :     typedef gregorian_calendar::year_type year_type;
<span class="lineNum">      41 </span>            :     typedef gregorian_calendar::month_type month_type;
<span class="lineNum">      42 </span>            :     typedef gregorian_calendar::day_type day_type;
<span class="lineNum">      43 </span>            :     typedef gregorian_calendar::day_of_year_type day_of_year_type;
<span class="lineNum">      44 </span>            :     typedef gregorian_calendar::ymd_type ymd_type;
<span class="lineNum">      45 </span>            :     typedef gregorian_calendar::date_rep_type date_rep_type;
<span class="lineNum">      46 </span>            :     typedef gregorian_calendar::date_int_type date_int_type;
<span class="lineNum">      47 </span>            :     typedef date_duration  duration_type;
<span class="lineNum">      48 </span>            : #if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR)
<span class="lineNum">      49 </span>            :     //! Default constructor constructs with not_a_date_time
<span class="lineNum">      50 </span>            :     date():
<span class="lineNum">      51 </span>            :       date_time::date&lt;date, gregorian_calendar, date_duration&gt;(date_rep_type::from_special(not_a_date_time))
<span class="lineNum">      52 </span>            :     {}
<a name="53"><span class="lineNum">      53 </span>            : #endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR</a>
<span class="lineNum">      54 </span>            :     //! Main constructor with year, month, day
<span class="lineNum">      55 </span><span class="lineCov">    3426639 :     date(year_type y, month_type m, day_type d)</span>
<span class="lineNum">      56 </span>            :       : date_time::date&lt;date, gregorian_calendar, date_duration&gt;(y, m, d)
<span class="lineNum">      57 </span>            :     {
<span class="lineNum">      58 </span><span class="lineCov">    3426639 :       if (gregorian_calendar::end_of_month_day(y, m) &lt; d) {</span>
<span class="lineNum">      59 </span><span class="lineNoCov">          0 :         boost::throw_exception(bad_day_of_month(std::string(&quot;Day of month is not valid for year&quot;)));</span>
<span class="lineNum">      60 </span>            :       }
<span class="lineNum">      61 </span><span class="lineCov">    3426639 :     }</span>
<span class="lineNum">      62 </span>            :     //! Constructor from a ymd_type structure
<span class="lineNum">      63 </span>            :     explicit date(const ymd_type&amp; ymd)
<span class="lineNum">      64 </span>            :       : date_time::date&lt;date, gregorian_calendar, date_duration&gt;(ymd)
<span class="lineNum">      65 </span>            :     {}
<span class="lineNum">      66 </span>            :     //! Needed copy constructor
<span class="lineNum">      67 </span>            :     explicit date(const date_int_type&amp; rhs):
<span class="lineNum">      68 </span>            :       date_time::date&lt;date,gregorian_calendar, date_duration&gt;(rhs)
<span class="lineNum">      69 </span>            :     {}
<span class="lineNum">      70 </span>            :     //! Needed copy constructor
<span class="lineNum">      71 </span>            :     explicit date(date_rep_type rhs):
<span class="lineNum">      72 </span>            :       date_time::date&lt;date,gregorian_calendar, date_duration&gt;(rhs)
<a name="73"><span class="lineNum">      73 </span>            :     {}</a>
<span class="lineNum">      74 </span>            :     //! Constructor for infinities, not a date, max and min date
<span class="lineNum">      75 </span><span class="lineCov">      48430 :     explicit date(special_values sv):</span>
<span class="lineNum">      76 </span><span class="lineCov">      48430 :       date_time::date&lt;date, gregorian_calendar, date_duration&gt;(date_rep_type::from_special(sv))</span>
<span class="lineNum">      77 </span>            :     {
<span class="lineNum">      78 </span><span class="lineCov">      48430 :       if (sv == min_date_time)</span>
<span class="lineNum">      79 </span>            :       {
<span class="lineNum">      80 </span><span class="lineNoCov">          0 :         *this = date(1400, 1, 1);</span>
<span class="lineNum">      81 </span>            :       }
<span class="lineNum">      82 </span><span class="lineCov">      48430 :       if (sv == max_date_time)</span>
<span class="lineNum">      83 </span>            :       {
<span class="lineNum">      84 </span><span class="lineNoCov">          0 :         *this = date(9999, 12, 31);</span>
<span class="lineNum">      85 </span>            :       }
<span class="lineNum">      86 </span>            : 
<span class="lineNum">      87 </span><span class="lineCov">      48430 :     }</span>
<span class="lineNum">      88 </span>            :     //!Return the Julian Day number for the date.
<span class="lineNum">      89 </span>            :     date_int_type julian_day() const
<span class="lineNum">      90 </span>            :     {
<span class="lineNum">      91 </span>            :       ymd_type ymd = year_month_day();
<span class="lineNum">      92 </span>            :       return gregorian_calendar::julian_day_number(ymd);
<span class="lineNum">      93 </span>            :     }
<span class="lineNum">      94 </span>            :     //!Return the day of year 1..365 or 1..366 (for leap year)
<span class="lineNum">      95 </span>            :     day_of_year_type day_of_year() const
<span class="lineNum">      96 </span>            :     {
<span class="lineNum">      97 </span>            :       date start_of_year(year(), 1, 1);
<span class="lineNum">      98 </span>            :       unsigned short doy = static_cast&lt;unsigned short&gt;((*this-start_of_year).days() + 1);
<span class="lineNum">      99 </span>            :       return day_of_year_type(doy);
<span class="lineNum">     100 </span>            :     }
<span class="lineNum">     101 </span>            :     //!Return the Modified Julian Day number for the date.
<span class="lineNum">     102 </span>            :     date_int_type modjulian_day() const
<span class="lineNum">     103 </span>            :     {
<span class="lineNum">     104 </span>            :       ymd_type ymd = year_month_day();
<span class="lineNum">     105 </span>            :       return gregorian_calendar::modjulian_day_number(ymd);
<span class="lineNum">     106 </span>            :     }
<span class="lineNum">     107 </span>            :     //!Return the iso 8601 week number 1..53
<span class="lineNum">     108 </span>            :     int week_number() const
<span class="lineNum">     109 </span>            :     {
<span class="lineNum">     110 </span>            :       ymd_type ymd = year_month_day();
<span class="lineNum">     111 </span>            :       return gregorian_calendar::week_number(ymd);
<span class="lineNum">     112 </span>            :     }
<span class="lineNum">     113 </span>            :     //! Return the day number from the calendar
<span class="lineNum">     114 </span>            :     date_int_type day_number() const
<span class="lineNum">     115 </span>            :     {
<span class="lineNum">     116 </span>            :       return days_;
<span class="lineNum">     117 </span>            :     }
<span class="lineNum">     118 </span>            :     //! Return the last day of the current month
<span class="lineNum">     119 </span>            :     date end_of_month() const
<span class="lineNum">     120 </span>            :     {
<span class="lineNum">     121 </span>            :       ymd_type ymd = year_month_day();
<span class="lineNum">     122 </span>            :       short eom_day =  gregorian_calendar::end_of_month_day(ymd.year, ymd.month);
<span class="lineNum">     123 </span>            :       return date(ymd.year, ymd.month, eom_day);
<span class="lineNum">     124 </span>            :     }
<span class="lineNum">     125 </span>            : 
<span class="lineNum">     126 </span>            :    private:
<span class="lineNum">     127 </span>            : 
<span class="lineNum">     128 </span>            :   };
<span class="lineNum">     129 </span>            : 
<span class="lineNum">     130 </span>            : 
<span class="lineNum">     131 </span>            : 
<span class="lineNum">     132 </span>            : } } //namespace gregorian
<span class="lineNum">     133 </span>            : 
<span class="lineNum">     134 </span>            : 
<span class="lineNum">     135 </span>            : 
<span class="lineNum">     136 </span>            : #endif
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
